<?php
// 本类由系统自动生成，仅供测试用途
namespace Home\Controller;

class IndexController extends BaseController {
    public function index(){
        $Article =M('Article');
        //获取全部文章->热门推荐
        $map['status']=1;
        $order='createtime desc';
        $art =$Article->join('__ARTICLE_CAT__ ON __ARTICLE__.classify = __ARTICLE_CAT__.cid','left')->where($map)->order($order)->limit(0,8)->select();
        

        //获取今日头条
        $map_index['is_index']=1;
        $map_index['status']=1;
        $art_index =$Article->join('__ARTICLE_CAT__ ON __ARTICLE__.classify = __ARTICLE_CAT__.cid','left')->where($map_index)->order($order)->limit(0,5)->select();
        
        //获取banner文章
        $map_banner['index_banner']=1;
        $map_banner['status']=1;
        $banner_index =$Article->join('__ARTICLE_CAT__ ON __ARTICLE__.classify = __ARTICLE_CAT__.cid','left')->where($map_banner)->order($order)->limit(0,4)->select();
        
        //获取精品导读
        $map_recom['index_recom']=1;
        $map_recom['status']=1;
        $index_recom =$Article->join('__ARTICLE_CAT__ ON __ARTICLE__.classify = __ARTICLE_CAT__.cid','left')->where($map_recom)->order($order)->limit(0,6)->select();
        
        
        //获取热门榜单
        $map_hot['index_hot']=1;
        $map_hot['status']=1;
        $index_hot =$Article->join('__ARTICLE_CAT__ ON __ARTICLE__.classify = __ARTICLE_CAT__.cid','left')->where($map_hot)->order($order)->limit(0,5)->select();
        
        //获取友情链接
        
        $map_link['status']=1;
        $Link =M('Link');
        $link =$Link->where($map_link)->select();
        
        $Ad =M('Picture');
        //获取首页广告位置1
        $map_ad['classify']=1;
        $ad =$Ad->where($map_ad)->find();
        
        //获取首页热门榜单轮播图片
        $map_hot_banner['classify']=4;
        $hot_banner =$Ad->where($map_hot_banner)->select();
        
        //获取品牌展示图片
        $map_show['classify']=5;
        $brandshow=$Ad->where($map_show)->select();
        
        
        
        $this->assign('article',$art);
        $this->assign('article_index',$art_index);
        $this->assign('article_banner',$banner_index);
        $this->assign('article_recom',$index_recom);
        $this->assign('article_hot',$index_hot);
        $this->assign('link',$link);
        $this->assign('ad',$ad);
        $this->assign('hot_banner',$hot_banner);
        $this->assign('brandshow',$brandshow);
        $this->display('index');
    }
    
    

}